<template>
	<view>
		<u-sticky bgColor="#6492FF" offsetTop=0 customNavHeight=0>
			<navbox title="我的信息"></navbox>
		</u-sticky>
		<view class="con">
			<view class="con__box">
				<view class="con__box__item">
					<view class="con__item__label">
						头像
					</view>
					<image src="/static/img/team/tx.png" class="con__box__item__tx" mode="aspectFill"></image>
				</view>
				<view class="con__box__item">
					<view class="con__item__label">
						姓名
					</view>
					<input v-model="form.name" type="text" disabled class="con__box__item__value" placeholder="请输入姓名"
						placeholder-style="font-size:26rpx" />
				</view>
				<view class="con__box__item">
					<view class="con__item__label">
						手机号
					</view>
					<input type="number" v-model="form.linkTel" class="con__box__item__value" placeholder="请输入手机号"
						placeholder-style="font-size:26rpx" />
				</view>
				<view class="con__box__item">
					<view class="con__item__label">
						微信号
					</view>
					<input type="text" v-model="form.wechatNo" class="con__box__item__value" placeholder="请输入微信号"
						placeholder-style="font-size:26rpx" />
				</view>
				<view class="con__box__item">
					<view class="con__item__label">
						QQ号
					</view>
					<input type="text" v-model="form.qqNo" class="con__box__item__value" placeholder="请输入QQ号"
						placeholder-style="font-size:26rpx" />
				</view>
			</view>
			<view class="con__footer">
				<u-button @click="submit" :loading="loading" text="提交" color="#6492FF" shape='circle'></u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		customeredit
	} from '@/api/user.js'
	export default {
		data() {
			return {
				form: {
					name: '',
					linkTel: '',
					qqNo: '',
					wechatNo: ''
				},
				loading: false
			};
		},
		onLoad() {
			for (let key in this.form) {
				this.form[key] = uni.getStorageSync('ytbuser')[key]
			}
		},
		methods: {
			submit() {
				//index不传参，默认就是上一个页面组件实例，此时可以使用上一个组件的methods等
				let {
					qqNo,
					wechatNo,
					linkTel
				} = this.form
				this.loading = true
				customeredit(this.form).then(res => {
					if (res.data.code == 200) {
						uni.navigateBack()
						this.getuserinfo()
						this.prePage().init()
						this.loading = false
					}
				})
			},
			prePage(index) {
				let pages = getCurrentPages();
				let prePage = pages[pages.length - (index || 2)];
				return prePage.$vm;
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;

	}

	.con {
		padding: 25rpx 16rpx;

		&__box {

			background: #FFFFFF;
			border-radius: 14rpx;
			padding: 30rpx 40rpx;

			&__item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1rpx solid #CDCDCD;
				height: 70rpx;

				&__label {
					font-family: Source Han Sans SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #3E3D3D;
					line-height: 26rpx;

				}

				&__value {
					width: 80%;
					font-family: Source Han Sans SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #707070;
					text-align: right;
				}

				&__tx {
					width: 54.86rpx;
					height: 54.86rpx;
					border-radius: 50%;
				}
			}

		}

		&__footer {
			padding: 25rpx 96rpx;

		}
	}
</style>